<?php

namespace App\Modules\CodeDesigner\DecoratorMode;

/**
 * 装饰类 用来扩展interface原有的功能
 */
abstract class Decorator implements ComponentInterface
{
    /**
     * @var Component
     */
    protected $component;

    /**
     * @param Component $component
     */
    public function setComponent($component): void
    {
        $this->component = $component;
    }

    public function operation()
    {
        // 定义属于自己的operation 同时实现父类原有的功能
        if ($this->component != null) {
            $this->component->operation();
        }
    }
}